﻿@using XRepair.Conventions.Enum
@using xCache = MvcXRepairAdmin.CacheData

@model XRepair.Models.Order

@{
    Layout = null;

    var activeCustomers = MvcXRepairAdmin.CacheData.Cache.GetAllActiveUsers().Where(x => x.RoleID == 4) ;
    var customerTypes = activeCustomers.Select(e => new SelectListItem { Text = e.Username, Value = e.ID.ToString() }).ToList();

    List<XRepair.Models.Service> activeServices = MvcXRepairAdmin.CacheData.Cache.GetAllActiveServices();
    var serviceTypes = activeServices.ConvertAll<SelectListItem>(x => new SelectListItem { Value = x.ID.Value.ToString(), Text = x.ServiceName });

    var activeTechnicians = MvcXRepairAdmin.CacheData.Cache.GetAllActiveUsers().Where(x => x.RoleID == 3);
    var technicianTypes = activeTechnicians.Select(e => new SelectListItem { Text = e.Username, Value = e.ID.ToString() }).ToList();

    List<XRepair.Models.OrderStatus> activeStatuss = MvcXRepairAdmin.CacheData.Cache.GetAllOrderStatus();
    var statusTypes = activeStatuss.ConvertAll<SelectListItem>(x => new SelectListItem { Value = x.ID.Value.ToString(), Text = x.Description });

    List<XRepair.Models.State> activeStates = MvcXRepairAdmin.CacheData.Cache.GetAllActiveStates();
    var stateTypes = activeStates.ConvertAll<SelectListItem>(x => new SelectListItem { Value = x.ID.Value.ToString(), Text = x.StateName });
    
    List<XRepair.Models.City> activeCities = MvcXRepairAdmin.CacheData.Cache.GetAllActiveCities();
    var cityTypes = activeCities.ConvertAll<SelectListItem>(x => new SelectListItem { Value = x.ID.Value.ToString(), Text = x.CityName });
}

@using (Html.BeginForm("Update", "Order", FormMethod.Post))
{
    @Html.ValidationSummary(true)
    <table>
        <tbody>
            <tr>
                <td>Customer</td>
                <td>
                    @Html.DropDownListFor(x => x.CustomerID, customerTypes)</td>
            </tr>
            <tr>
                <td>Service</td>
                <td>
                    @Html.DropDownListFor(x => x.ServiceID, serviceTypes)</td>
            </tr>
            <tr>
                <td>Technician</td>
                <td>
                    @Html.DropDownListFor(x => x.TechnicianID, technicianTypes)</td>
            </tr>
            <tr>
                <td>Accepted At</td>
                <td>
                    @Html.TextBoxFor(x => x.AcceptedAt)
                </td>
            </tr>
            
            <tr>
                <td>Technician Description</td>
                <td>
                    @Html.TextBoxFor(x => x.TechnicianDescription) </td>
            </tr>
            <tr>
                <td>Due Date</td>
                <td>
                    @Html.TextBoxFor(x => x.DueDate) </td>
            </tr>
            <tr>
                <td>Status</td>
                <td>
                    @Html.DropDownListFor(x => x.StatusID, statusTypes)</td>
            </tr>


            <tr>
                <td>Extra Fee</td>
                <td>
                    @Html.TextBoxFor(x => x.ExtraFee) </td>
            </tr>
            <tr>
                <td>Extra Note</td>
                <td>
                    @Html.TextBoxFor(x => x.ExtraFeeNote) </td>
            </tr>
            <tr>
                <td>Billing Address</td>
                <td>
                    @Html.TextBoxFor(x => x.BillingAddress) </td>
            </tr>
            <tr>
                <td>Shipping Address</td>
                <td>
                    @Html.TextBoxFor(x => x.ShippingAddress) </td>
            </tr>
            <tr>
                <td>State</td>
                <td>
                    @Html.DropDownListFor(x => x.StateID, stateTypes) </td>
            </tr>
            <tr>
                <td>City</td>
                <td>
                    @Html.DropDownListFor(x => x.CityID, new List<SelectListItem> { new SelectListItem { Value = string.Empty, Text = "Waiting for selected state" } })</td>
            </tr>
            <tr>
                <td>Zip Code</td>
                <td>
                    @Html.TextBoxFor(x => x.ZipCode) </td>
            </tr>
        </tbody>
    </table>
    
    @Html.HiddenFor(x => x.ID);
    
    <input type="submit" value="Update" /><input type="button" value="Cancel" id="btnCancelEdit" />
   
}
@*@section lazy
{
    <script type="text/javascript" src="@Url.Content(@"~\Scripts\jquery-ui-1.8.20.js")"></script>
    <script type="text/javascript">
        $(function () {
            



        });
</script>
}*@
